import unittest
from jd_HTMLTestRunner import HTMLTestRunner
from execute.MyTestCase import MyTestCase
import os



def create_suite():
    suite = unittest.TestSuite()
    suite.addTest(MyTestCase("test_case1"))
    suite.addTest(MyTestCase("test_case2"))
    suite.addTest(MyTestCase("test_case3"))
    return suite

if __name__ == "__main__":
    suite = create_suite()
    report_path = "test_report.html"

    # 创建 HTMLTestRunner 实例并运行测试
    with open(report_path, 'wb') as report_file:
        runner = HTMLTestRunner(
            stream=report_file,  # 传递文件对象
            verbosity=2,
            title='测试报告',
            description='这是一个测试报告的描述',
            tester='蔡得利'  # 指定测试人员
        )
        runner.run(suite)  # 直接传递 suite

    print(f"测试报告已生成，路径为：{os.path.abspath(report_path)}")